<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Layui</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="layui-v2.5.7/layui/css/layui.css" media="all">
		<!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
	</head>
	<body>
		<div class="layui-form">

			<div class="layui-form-item">
				<label class="layui-form-label">行内选择框</label>
				<div class="layui-input-inline">
					<select name="province" id="province" lay-filter='province' lay-search>
					</select>
				</div>
				<div class="layui-input-inline">
					<select name="city" id="city" lay-filter='city'>
					</select>
				</div>
				<div class="layui-input-inline">
					<select name="address" id="address" lay-filter='address'>
					</select>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">爱好</label>
				<div class="layui-input-block">
					<select name="interest" id="interest" lay-filter="interest">
					</select>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">职业</label>
				<div class="layui-input-block">
					<select name="profession" id='profession' lay-filter="profession">
					</select>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">充值金额</label>
				<div class="layui-input-block">
					<select name="money" id="money" lay-filter="money">
					</select>
				</div>
			</div>
		</div>

		<script src="layui-v2.5.7/layui/layui.js" charset="utf-8"></script>
		<script src="js/layui_select.js" charset="utf-8"></script>
		<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
		<script>
			//多级联动
			var laySelect = new LaySelect();
			laySelect.select({
				elems: ['#province', '#city', '#address'],
				otherOption: true,
				linkage:true, //是否联动
				layFilters: ['province', 'city', 'address'],
				defaultValues:['anA01','anA01-01','anA01-01-02'],
				//keyValues:[{key:'name',value:'code',extra:'treeid'}],
				url: 'http://192.168.0.125:6889/rest/test/getMsg',
				//jsonData: resDt.data,
				where: {
					root: 'zhongguo'
				},
				change: function(data, form) {
					console.log(data);
					console.log(form);
					//return false;
				},
				//request:{limit:10},
				/* parseData: function(res) {
					console.log(res);
					return {
						//code: res.code,
						success: true, //设置为true他才会执行
						msg: '',
						//data:res 
						data: res.resultValue //这里肯定是数组对象
					};
				}, */
			})
			
			
			//非联动
			var laySelect2 = new LaySelect();
			laySelect2.select({
					elems: ['#interest', '#profession', '#money'],
					otherOption: true,
					layFilters: ['interest', 'profession', 'money'],
					defaultValues: ['game', 'jiaoshi', '0050'],
					keyValues: [{
						key: 'interestName',
						value: 'inCode',
						extra: 'id'
					}, {
						key: 'name',
						value: 'proCode'
					}],
					url: 'http://192.168.0.125:6889/rest/test/getMsg',
					type: 'post',
					//jsonData: resDt.data,
					where: {
						root: 'zhongguo'
					},
					change: function(data, form) {
						console.log(data);
						//console.log(form);
						//return false;
					},
					//request:{limit:10},
					parseData: function(res) {
						//console.log(res);
						return {
							//code: res.code,
							success: true, //设置为true他才会执行
							msg: '',
							//data:res 
							data: res.resultValue //这里肯定是数组对象
						};
					},
				})
			
		</script>

	</body>
</html>
